 package valueObject;

import entity.Node;
import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author Juan Hernández Serrato
 */
public class NodeVO implements ValueObject<Node> {
    private Integer id;
    private String type;
    private String description;
    private String content;
    private CourseVO course;
    private Collection<NodeVO> nodes;
    private NodeVO parentNode;
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer idNode) {
        this.id = idNode;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String data) {
        this.content = data;
    }

    public CourseVO getCourse() {
        return course;
    }

    public void setCourse(CourseVO course) {
        this.course = course;
    }

    public Collection<NodeVO> getNodes() {
        return nodes;
    }

    public void setNodes(Collection<NodeVO> nodeCollection) {
        this.nodes = nodeCollection;
    }

    public NodeVO getParentNode() {
        return parentNode;
    }

    public void setParentNode(NodeVO nodoPadre) {
        this.parentNode = nodoPadre;
    }

    @Override
    public Node toEntity() {
        Node node = new Node();
        node.setCourseidCourse(course.toEntity());
        node.setData(content);
        node.setDescription(description);
        node.setIdNode(id);
        ArrayList<Node> nodesE = new ArrayList<Node>();
        if(nodes != null){
            for(NodeVO n : nodes){
                nodesE.add(n.toEntity());
            }
        }
        node.setNodeCollection(nodesE);
        if(parentNode != null) 
           node.setNodoPadre(parentNode.toEntity());
        node.setType(type);
        return node;
    }
}
